﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient; 
using Microsoft.ApplicationBlocks.Data;

namespace NTTDATA.BEENChina.ResultCertification.DataStore
{
    public class JaMailClientAccess : IJaMailClientAccess
    {
        private static string ConnectionString
        {
            get
            {
                return System.Configuration.ConfigurationManager.AppSettings["ResultCertificationDB"];
            }
        }

        public List<string> GetJaMailAddress()
        {

            string sql = "SELECT [MailAddress]  FROM [JaMailAddress] ";

            List<string> mailAddress = null;

            try
            {
                using (SqlDataReader reader = SqlHelper.ExecuteReader(ConnectionString, System.Data.CommandType.Text, sql))
                {
                    while (reader.Read())
                    {

                        if (mailAddress == null)
                            mailAddress = new List<string>();
                       
                        mailAddress.Add(reader.GetString(0));
                      
                    }

                    reader.Close();
                }
            }
            catch (Exception ex)
            {
                Log.Console.Error("JaMailClientAccess.GetJaMailAddress", ex);
            }

            return mailAddress;
        }
    }
}
